package lab01;

import java.util.Scanner;

/**
 * Created by 林云志 on 2017/10/8.
 */
public class Test05 {
    public static void main(String[] args) {
        System.out.println("请问您想从一加到多少？");
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;

        //for语句
        for (int i=1;i<=n;i++){
            sum +=i;
        }
        System.out.println(sum);
        //while语句
        System.out.println("请问您想从一加到多少？");
        sum=0;
        n = sc.nextInt();
        int i = 0;
        while (i<n+1){
            sum+=i;
            i++;
        }
        System.out.println(sum);
        //do while语句
        System.out.println("请问您想从一加到多少？");
        sum=0;
        i=0;
        n = sc.nextInt();
        do {
            sum+=i;
            i++;
        }while (i<n+1);
        System.out.println(sum);
    }


}
